package com.dq.controller.op.opboss.finance;

import com.dq.exception.customException.AdminException;
import com.dq.controller.in.WorkRoyaltyQuery;
import com.dq.vo.Vo;

import com.dq.domain.sys.section.SysSection;
import com.dq.domain.setup.WorkRoyaltySet;
import com.dq.service.AllService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @Author luchangtong
 * @Date 2019/12/20 21:31
 */
@RestController
@RequestMapping("/sys/boss/WorkRoyalty")
@Api(description = "提成设置")
public class BossWorkRoyaltyController extends AllService {

    @ApiOperation("提成列表")
    @PostMapping("list")
    public Vo list(@RequestBody WorkRoyaltyQuery workRoyaltyQuery)throws AdminException{
        return workRoyaltyService.list(workRoyaltyQuery);
    }

    @ApiOperation("添加提成")
    @PostMapping("add/{orgPositionId}")
    public Vo add(@PathVariable Long orgPositionId,@RequestBody WorkRoyaltySet workRoyaltySet)throws AdminException{
        SysSection section = shiroService.getDept();
        if(section == null){
            throw new AdminException("用户门店信息异常");
        }
        workRoyaltyService.add(section.getId(),orgPositionId,workRoyaltySet);
        return new Vo(HttpStatus.OK);
    }

    @ApiOperation("编辑提成")
    @PostMapping("edit/{orgPositionId}")
    public Vo edit(@PathVariable Long orgPositionId,@RequestBody WorkRoyaltySet workRoyaltySetEdit)throws AdminException{
        SysSection section = shiroService.getDept();
        if(section == null){
            throw new AdminException("用户门店信息异常");
        }
        return workRoyaltyService.edit(section.getId(),orgPositionId,workRoyaltySetEdit);
    }
    @ApiOperation("删除提成")
    @PostMapping("delete/{id}")
    public Vo edit(@PathVariable Long id)throws AdminException{
        return workRoyaltyService.delete(id);
    }

}
